<template>
  <div>
    <div class="jobItem" v-for="item in jobList" :key="item.id">
      <h4 class="postName">{{item.post}}</h4>
      <div class="footer">
        <div>
          <span>{{item.workPlace}}</span>
        </div>
        <div @click="toDetail(item.id)" class="lookDetail">查看详情</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    companyId: {
      type: Number
    }
  },
  created () {
    this.getJobList()
  },
  data () {
    return {
      jobList: []
    }
  },
  methods: {
    toDetail (id) {
      this.$router.push(`/job/detail/${id}`)
    },
    async getJobList () {
      const res = await this.$http.get(`/job/jobList/${this.companyId}`)
      this.jobList = res.data
    }
  }
}
</script>

<style scoped lang="less">
.lookDetail {
  cursor: pointer;
}
.jobItem {
  border: 1px solid #eee;
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 10px;
  .postName {
    margin-bottom: 5px;
  }
}
.footer {
  display: flex;
  justify-content: space-between;
}
</style>
